package com.ysd.lis.controller.emr;


import com.ysd.common.Result;
import com.ysd.lis.controller.pub.BaseController;
import com.ysd.lis.entity.emr.EmrGrade;
import com.ysd.lis.request.DeleteParam;
import com.ysd.lis.service.emr.EmrGradeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author whx
 * @since 2025-06-04
 */
@RestController
@RequestMapping("/emr/grade")
public class EmrGradeController extends BaseController {

    @Autowired
    private EmrGradeService  emrGradeService;

    @ApiOperation("查询")
    @GetMapping("/findEmrGradeList")
    public Result findEmrGradeList(EmrGrade emrGrade) {
        return emrGradeService.findEmrGradeList(emrGrade);
    }


    @ApiOperation("添加功能")
    @PostMapping("/addEmrGrade")
    public Result addEmrGrade(@RequestBody EmrGrade emrGrade) {
        return emrGradeService.addEmrGrade(emrGrade);
    }

    @ApiOperation("编辑功能")
    @PostMapping("/editEmrGrade")
    public Result editEmrGrade(@RequestBody EmrGrade emrGrade) {
        return emrGradeService.editEmrGrade(emrGrade);
    }


    @ApiOperation("删除功能")
    @PostMapping("/deleteEmrGrade")
    public Result deleteEmrGrade(@RequestBody DeleteParam deleteParam) {
        boolean b = emrGradeService.removeByIds(Arrays.asList(deleteParam.getIds().split(",")));
        if (b) {
            return Result.succ(1, "删除成功", "");
        }
        return Result.fail("删除失败");
    }
}
